<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <meta
    name="viewport"
    content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
    />
  <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
  <meta content="1280*720" name="page-view-size"/>
  <title>QQ音乐</title>

  <%# 由于没有 session, csrf 可以关闭了 %>
  <%#= csrf_meta_tags %>
  <%= csp_meta_tag %>

  <%= stylesheet_link_tag 'application' %>

  <%= javascript_include_tag 'show_error' unless Rails.env.production? %>
  <%= javascript_include_tag 'es5-polyfill.min' %>

  <%# 垃圾机顶盒...连classList都没有的 %>
  <%= javascript_include_tag 'dom4' %>
  <%# 机顶盒的requestAnimationFrame存在, 但是错误实现, 将所有使用 %>
  <%= javascript_include_tag 'rAF.min' %>
  <%= javascript_include_tag 'html5-dataset.min' %>

  <%= javascript_include_tag 'jquery-2.2.4.min' %>

  <%= javascript_include_tag 'js.cookie.min' %>
  <%= javascript_include_tag 'bind_method' %>
  <%= javascript_include_tag 'back_with_prev' %>

  <% unless Rails.env.production? %>
    <%# 某些机顶盒vconsole会造成死机 %>
    <%= javascript_include_tag 'vconsole.min' %>
    <script type="text/javascript" charset="utf-8">
        var vc = new VConsole();
        bind_method(document, "keydown", function (e) {
                e = e || window.event;
                var keyValue = e.which || e.keyCode;
                switch (keyValue) {
                    case 81: // 键盘q
                    case 257: //频道+
                        setTimeout(function () {
                            vc.show();
                        }, 1000);
                        break;
                    case 87:  // 键盘w
                    case 258: //频道-
                        setTimeout(function () {
                            vc.hide();
                        }, 1000);
                        break;
                    case 69: // 键盘e
                    case 106:
                    case 280:
                        vc.openFold();
                        break;
                }
            }
        );
    </script>
  <% end %>

  <%= javascript_include_tag 'interval.min' %>
  <% if ENV['ON_PC'] %>
    <%= javascript_include_tag 'authentication' %>
  <% end %>

  <% if Rails.env.production? %>
    <%= javascript_include_tag 'FocusEngine.min' %>
  <% else %>
    <%# 注释第一句 e.preventDefault(); 不然会阻塞一切键盘行为 %>
    <%= javascript_include_tag 'FocusEngine.development' %>
  <% end %>

  <%#= javascript_include_tag 'TVUtil.min' %>
</head>

<script type="text/javascript" charset="utf-8">
    $(function () {
        window.focus();
        window.root = FocusEngine.render();
    });
</script>

<body
  id="<%= controller.controller_name %>-<%= controller.action_name %>"
  fe-role="Switch" fe-cfg="disable:yes"
>

<div id="app" class="<%= dynamic_background %>">
  <div id="error"></div>
  <%= render partial: "shared/header" unless is_fullscreen_play? %>
  <%= yield %>
  <%= render partial: "shared/footer" if has_footer %>
</div>

</body>
</html>
